package pl.pw.mkmw.pnganimator.utils;

/**
 *
 * @author Michał
 */
public class ByteArrayUtils {

    public static byte[] concate(byte[] a, byte[] b) {
        byte[] c = new byte[a.length + b.length];
        System.arraycopy(a, 0, c, 0, a.length);
        System.arraycopy(b, 0, c, a.length, b.length);

        return c;
    }

    public static String bytesPrint(byte[] x) {
        StringBuilder sb = new StringBuilder("[");
        for (int i = 0; i < x.length; i++) {
            sb.append(" ").append(x[i] & 0xFF);
        }
        sb.append("]");
        return sb.toString();
    }

    public static String bytesHEXPrint(byte[] x) {
        StringBuilder sb = new StringBuilder("[");
        for (int i = 0; i < x.length; i++) {
            sb.append(" ").append(Integer.toHexString(0xFF & x[i]));
            if ((i + 1) % 4 == 0) {
                sb.append(" |");
            }
        }
        sb.append("]");
        return sb.toString();
    }
}
